import { http } from "@/utils";

export function getRoleList(params = {}) {
  return http.post("/system/role/list", params);
}

export function getRoleDetail(roleId) {
  return http.get(`/system/role/detail/${roleId}`);
}

export function addRole(params) {
  return http.post("/system/role/insert", params);
}

export function updateRole(params) {
  return http.post("/system/role/update", params);
}

export function updateRoleStatus(params) {
  return http.post("/system/role/update/status", params);
}

export function deleteRole(roleId) {
  return http.post("/system/role/delete", roleId);
}

export function deleteBatchRole(roleIds) {
  return http.post("/system/role/deleteBatch", roleIds);
}

export function getExportParams() {
  return http.get("/system/role/export/params");
}

export function exportRole(params = {}) {
  return http.post("/system/role/export", params, {
    responseType: "blob",
  });
}

// ----- 分配用户 -----
export function getAuthedUserList(roleId, params = {}) {
  return http.post(`/system/role/auth/${roleId}/authed-users`, params);
}

export function getUnAuthUserList(roleId, params = {}) {
  return http.post(`/system/role/auth/${roleId}/unAuth-users`, params);
}

export function addAuthUsers(roleId, userIds) {
  return http.post(`/system/role/auth/${roleId}/add`, userIds);
}

export function cancelAuthUser(roleId, userIds) {
  return http.post(`/system/role/auth/${roleId}/cancel`, userIds);
}
